package com.jzg.jcptadmin.adpter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.jzg.jcptadmin.R;
import com.jzg.jcptadmin.data.vo.CommentData;

import java.util.List;

/**
 * Created by jzg on 2015/12/24.
 */
public class TaskViewAdapter extends BaseAdapter {
    public List<CommentData> list;
    public Context context;
    private ViewHolder viewHolder;

    public TaskViewAdapter(List<CommentData> list, Context context) {
        this.list = list;
        this.context = context;

    }

    public void updatalist(List<CommentData> list) {
        this.list = list;
    }

    @Override
    public int getItemViewType(int position) {
        return list.get(position).getType();
    }

    @Override
    public int getCount() {
        //return list.size();
        return 0;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = View.inflate(context, R.layout.task_view_item, null);
            viewHolder.iv_usernameimage = (ImageView) convertView.findViewById(R.id.iv_usernameimage);
            viewHolder.tv_content = (TextView) convertView.findViewById(R.id.tv_content);
            viewHolder.tv_time = (TextView) convertView.findViewById(R.id.tv_time);
            viewHolder.tv_username = (TextView) convertView.findViewById(R.id.tv_username);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.tv_username.setText(list.get(position).getUsername());
        viewHolder.tv_state.setText("");
        viewHolder.tv_time.setText(list.get(position).getTime());
        viewHolder.tv_content.setText(list.get(position).getContnet());


        return convertView;
    }

    @Override
    public int getViewTypeCount() {
        return super.getViewTypeCount();
    }

    public class ViewHolder {
        public ImageView iv_usernameimage;
        public TextView tv_username;
        public TextView tv_time;
        public TextView tv_content;
        public TextView tv_state;

    }

}
